"""
@Project:Efficient
@File:serializer.py
@Author:郑凯乐
@Date:15:01
"""
from rest_framework import serializers
from .models import *

# 用户序列化器
class UserSer(serializers.ModelSerializer):
    stations = serializers.PrimaryKeyRelatedField(queryset=StationModel.objects.all())

    stations_name = serializers.SerializerMethodField(read_only=True)

    def get_stations_name(self, obj):
        return obj.stations.name

    class Meta:
        model = UserModel
        fields = '__all__'

# 职级序列化器
class RankSer(serializers.ModelSerializer):
    class Meta:
        model = RankModel
        fields = '__all__'
# 部门序列化器
class SectionSer(serializers.ModelSerializer):
    class Meta:
        model = SectionModel
        fields = '__all__'

# 目录序列化器
class CataSer(serializers.ModelSerializer):
    class Meta:
        model = Catalog
        fields = '__all__'

# 菜单序列化器
class MenuSer(serializers.ModelSerializer):
    class Meta:
        model = Menu
        fields = '__all__'

# 材料序列化器
class MaterialsSer(serializers.ModelSerializer):
    class Meta:
        model = MaterialsModel
        fields = '__all__'

# 工资序列化器
class PriceSer(serializers.ModelSerializer):
    class Meta:
        model = PriceModel
        fields = '__all__'
